 import record from './record';
//  import $ from 'jquery'
//  $(function(){
//      $('img').load(function(){
//          console.log('img load',this)
//      })
//  })
domReady(function(){
    // console.log('domReady')
})
 function domReady(fn) {
 
     if (document.addEventListener) {
         //jquery中已经省略false，false解决低版本火狐兼容性问题
         document.addEventListener('DOMContentLoaded', fn, false);
     } else {
         document.attachEvent('onreadystatechange', function() {
             if (document.readyState == 'complete') {
                 fn();
             }
         });
     }
 }
//  new Promise

//  console.log('ssssss')
 domReady(function() {
     let imgs = document.getElementsByTagName('img')
    // console.log(imgs)
     for (let i = 0; i < imgs.length; i++) {
         let startTime = (+new Date());
        //  console.log(imgs[i].readystate)
        //  console.log(imgs[i].DOMContentLoaded)
        //  var link = document.createElement('link')
        //  link.href ==imgs[i].href;
        //  link.rel='stylesheet'
        //  link.type='text/css'
        //  document.body.appendChild(link)
        //  document.body.removeChild(link)
        //  link
        imgs[i].onload = function() {
            let endTime =  (+new Date())
            //  console.log(this)
            //  console.log('imgs onload')
             record.performance.push({
                 type: 'img',
                 done: endTime-startTime,
                 url: this.src,
                 startTime: startTime,
                 endTime: endTime
             })
         }
     }
    //  console.log(imgs)
 })


 export default _ => {


 }